package com.lemurian.entity;
// Generated Jan 13, 2012 10:56:58 AM by Hibernate Tools 3.2.1.GA


import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Type;

import com.lemurian.entity.utils.DefaultPersistence;

/**
 * Groups generated by aditya
 */

@Entity
@Table(name="tb_group")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@BatchSize(size=100)
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Groups extends DefaultPersistence implements Serializable {

	private static final long serialVersionUID = 1L;

	@Basic(optional = false)
    @Column(length = 128, nullable = false, unique = true, name = "group_name")
    private String groupName;

    @Temporal(value = TemporalType.DATE)
    @Column(name = "create_date", length = 6)
    private Date createdDate;

    @Column(name = "status", nullable = false)
    @Type(type="true_false")
    private boolean status;

    @ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(
		name = "tb_group_menu",
		joinColumns = {@JoinColumn(name = "group_id")},
		inverseJoinColumns = {@JoinColumn(name = "menu_id")},
		uniqueConstraints={@UniqueConstraint(columnNames={"group_id","menu_id"})}
	)
	@BatchSize(size=1000)
	@IndexColumn(name="menu_seq")
	@OrderBy(clause = "menu_seq asc")
    private List<Menu> menus = new LinkedList<Menu>();

    @ManyToOne()
    @JoinColumn(name = "group_type_id")
    private Category groupType;
    
    public Groups() {
    }

    public String getGroupName() {
        return this.groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public List<Menu> getMenus() {
        return menus;
    }

    public void setMenus(List<Menu> menus) {
        this.menus = menus;
    }

    /**
     * @return the createdDate
     */
    public Date getCreatedDate() {
        return createdDate;
    }

    /**
     * @param createdDate the createdDate to set
     */
    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    /**
     * @return the status
     */
    public boolean isStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(boolean status) {
        this.status = status;
    }

	public Category getGroupType() {
		return groupType;
	}

	public void setGroupType(Category groupType) {
		this.groupType = groupType;
	}
    
}